Models
---

Captures the behavior of the application in terms of its problem domain.

How to create a model 
---

Create ``./app/models/MyModel.js`` where MyModel is the name

```javascript
/**
 * Filename should be camelcase, while
 * classname should be PascalCase.
 * @file MyModel
 *
 */
const Model = require("./model");

/**
 * Description of model.
 *
 * @class MyModel
 */
class MyModel extends Model {
  /**
   * @constructor
   */
  constructor(tableName) {
    super(tableName);
  }

  /**
   * Save a new entry in local storage.
   *
   * @method store
   * @param {Object} payload
   * @param {String} payload.name
   * @return {Promise}
   */
  store(payload) {
    // Additional validation specific to my model.
    if (!("name" in payload)) {
      return Promise.reject({
        status: "error",
        message: "MyModel:store payload does not have name"
      });
    }
    super.store(payload);
  }

  /**
   * Chack if entry is in datastore.
   * Here we want to fetch by id only.
   *
   * @method isInCache
   * @param {Object} entry
   * @param {Number} entry.id
   * @return {Promise}
   */
  isInCache(entry) {
    if (!("id") in entry) {
      return Promise.reject({
        status: "error",
        message: "MyModel:isInCache entry does not have id"
      });
    }
    super.isInCache(entry);
  }
}
```

You can now instanciate it: 
```javascript
const MyModel = require("./app/models/myModel");

let myModel = new MyModel("pet");

// Store a pet
myModel.store({name: "Owly"})
    .then(payload => console.log(payload));
```